|
|
@@ -12,12 +12,10 @@ module Agents
|
12
|
12
|
|
13
|
13
|
You can use this agent to retrieve tracking data. You have to provide a specific `get` request and its associated option.
|
14
|
14
|
|
15
|
|
- To get all trackings for your packages please enter `get` for key and `trackings` for the option.
|
16
|
|
- To get tracking for a specific tracking number, add the extra keys `slug`, `tracking_number` and its associated values.
|
|
15
|
+ To get all trackings for your packages please enter `path` for key and `trackings` for the option.
|
|
16
|
+ To get tracking for a specific tracking number, add the extra keys `slug`, `tracking_number` and their associated values. Set `single_tracking_request` to true.
|
17
|
17
|
|
18
|
|
- Set `single_tracking_request` to true as well.
|
19
|
|
-
|
20
|
|
- To get the last checkpoint of a package set key to `get` and option to `last_checkpoint`. Please provide `slug` and `tracking_number`
|
|
18
|
+ To get the last checkpoint of a package set key to `path` and option to `last_checkpoint`. Please provide `slug` and `tracking_number`
|
21
|
19
|
|
22
|
20
|
`slug` is a unique courier code.
|
23
|
21
|
|
|
|
@@ -26,12 +24,12 @@ module Agents
|
26
|
24
|
Required Options:
|
27
|
25
|
|
28
|
26
|
* `api_key` - YOUR_API_KEY.
|
29
|
|
- * `get and its associated options`
|
|
27
|
+ * `path and its associated options`
|
30
|
28
|
MD
|
31
|
29
|
|
32
|
30
|
event_description <<-MD
|
33
|
31
|
A typical tracking event has 3 objects (attributes, tracking, and checkpoint) and it looks like this
|
34
|
|
- {
|
|
32
|
+ {
|
35
|
33
|
"meta": {
|
36
|
34
|
"code": 200
|
37
|
35
|
},
|
|
|
@@ -95,19 +93,19 @@ module Agents
|
95
|
93
|
"coordinates": [],
|
96
|
94
|
"state": null,
|
97
|
95
|
"zip": null
|
98
|
|
- },
|
|
96
|
+ },
|
99
|
97
|
...
|
100
|
98
|
]
|
101
|
99
|
},
|
102
|
100
|
...
|
103
|
101
|
]
|
104
|
102
|
}
|
105
|
|
- }
|
|
103
|
+ }
|
106
|
104
|
MD
|
107
|
105
|
|
108
|
106
|
def default_options
|
109
|
107
|
{ 'api_key' => 'YOUR_API_KEY',
|
110
|
|
- 'get' => '/trackings'
|
|
108
|
+ 'path' => '/trackings'
|
111
|
109
|
}
|
112
|
110
|
end
|
113
|
111
|
|
|
|
@@ -125,7 +123,7 @@ module Agents
|
125
|
123
|
|
126
|
124
|
def validate_options
|
127
|
125
|
errors.add(:base, "You need to specify a api key") unless options['api_key'].present?
|
128
|
|
- errors.add(:base, "You need to specify a get request") unless options['get'].present?
|
|
126
|
+ errors.add(:base, "You need to specify a path request") unless options['path'].present?
|
129
|
127
|
end
|
130
|
128
|
|
131
|
129
|
def check
|
|
|
@@ -144,11 +142,11 @@ module Agents
|
144
|
142
|
end
|
145
|
143
|
|
146
|
144
|
def event_url
|
147
|
|
- base_url + "#{URI.encode(interpolated[:get].to_s)}"
|
|
145
|
+ base_url + "#{URI.encode(interpolated[:path].to_s)}"
|
148
|
146
|
end
|
149
|
147
|
|
150
|
148
|
def single_or_checkpoint_tracking_url
|
151
|
|
- base_url + "#{URI.encode(interpolated[:get].to_s)}/#{URI.encode(interpolated[:slug].to_s)}/#{URI.encode(interpolated[:tracking_number].to_s)}"
|
|
149
|
+ base_url + "#{URI.encode(interpolated[:path].to_s)}/#{URI.encode(interpolated[:slug].to_s)}/#{URI.encode(interpolated[:tracking_number].to_s)}"
|
152
|
150
|
end
|
153
|
151
|
|
154
|
152
|
def request_options
|